<!--
 * @Author jiangzhiwei
 * @Date 2023-08-01 17:36:22
 * @LastEditors jiangzhiwei
 * @LastEditTime 2023-08-01 19:24:52
 * @FilePath \test-cron\src\views\CronView.vue
 * @Description cron表达式窗口组件
-->
<script setup lang="ts">
import { ref } from 'vue'
import YcCron from '@/components/yc-cron'

const dialogVisible = ref(false)
const cron = ref('')

const emit = defineEmits<{
  (e: 'change', data: string): void
}>()

defineExpose({ open })

/** 打开 */
function open (exp: string) {
  dialogVisible.value = true
  cron.value = exp
}

/** 确定 */
function sure () {
  dialogVisible.value = false
  emit('change', cron.value)
}
</script>

<template>
  <el-dialog
    v-model="dialogVisible"
    title="cron"
    width="700px"
  >
    <YcCron v-model="cron" type="spring"></YcCron>
    
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">Cancel</el-button>
        <el-button type="primary" @click="sure">
          Confirm
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>